﻿<!--#include file="h.asp"--><%
'
'	七色虎建站系统
'	用户密保页面
'	2012.9.9

Sub main
	checkLogin()'验证登录
	Dim a,userid,rs,body_
	Dim name,nameLen
	Dim userName,set_,questionList_
	Dim qsid,ans
	hu.title = "密保中心"
	body_ = "[div=nav]-"&hu.url("?aid=index","首页")&"-"&hu.url("bbs_user.asp","会员中心")&"-密保中心[/div]"
	a=getN("a", 0)
	userid=user_array(0)
	userName=user_array(1)
	setSecret_=ifSetSecret(userid)'是否设置了密保
	If a=0 Then
		body_ = body_ & ""
		If setSecret_ Then
			'已设密保
			body_ = body_ & "当前状态：已设密保"&hu.url("bbs_safe.asp?a=2","修改")
		Else
			'未设密保
			body_ = body_ & "当前状态：没有密保"&hu.url("bbs_safe.asp?a=1","设置")&"<br/>[div=tip]忘记密码可通过密保取回[/div]"
		End If
	ElseIf a=1 Then'初设密保
		If Not setSecret_ Then
			'未设密保
			Set rs=hu.conn("select id,question from 74hu_passwordask order by id")
			If Not rs.eof Then
				While Not rs.eof
					If questionList_="" Then questionList_=rs("id")
					questionList_ = questionList_ & "||" & rs("id") &"$$" & rs("question")
					rs.movenext
				Wend
			Else
				rupt "错误","系统发生错误，请与管理员联系"
			End If
			Set rs=Nothing
			Dim formarray(3)
			formarray(0) = http_path&"bbs_safe.asp||post||提交||问题："
			formarray(1) = "select||qs$$"&questionList_&"||<br/>答案："
			formarray(2) = "input||ans$$$$18$$20||<br/>"
			formarray(3) = "hidden||a$$11||"&bbsSid&"$$"&sid&"||"
			body_ = body_ & hu.getForm(formarray) &"<br/>"& hu.url("bbs_safe.asp", "密保首页")
		Else
			'已设密保
			body_ = body_ & "你已设置了密保，请不要重复刷新！<br/>"& hu.url("bbs_safe.asp", "密保首页")
		End If
	Elseif a=11 Then'初设密保
		qsid=getN("qs", 1)
		Set rs=hu.conn("select top 1 id from 74hu_passwordask where id="&qsid)
		If rs.eof Then rupt "错误", "请选择密保问题"
		Set rs=Nothing
		ans=getD("ans", "")
		If ans="" Then rupt "错误", "密保答案不能为空"&hu.url("bbs_safe.asp","返回密保中心")
		If Not setSecret_ Then
			'未设密保
			hu.conn("insert into 74hu_password (userid,ask1,ans1)values("&userid&","&qsid&",'"&ans&"')")
			body_ = body_ & "密保设置成功"
		Else
			'已设密保
			body_ = body_ & "你已设置了密保，请不要重复刷新！"
		End If
		body_ = body_ & "<br/>"& hu.url("bbs_safe.asp", "密保首页")
	Elseif a=2 Then'修改密保
		Set rs=hu.conn("select id,question from 74hu_passwordask order by id")
			If Not rs.eof Then
				While Not rs.eof
					If questionList_="" Then questionList_=rs("id")
					questionList_ = questionList_ & "||" & rs("id") &"$$" & rs("question")
					rs.movenext
				Wend
			Else
				rupt "错误","系统发生错误，请与管理员联系"
			End If
			Set rs=Nothing
			Dim formarray2(5)
			formarray2(0) = http_path&"bbs_safe.asp||post||提交||原问题："
			formarray2(1) = "select||qs$$"&questionList_&"||<br/>原答案："
			formarray2(2) = "input||ans$$$$18$$20||<br/>新问题："
			formarray2(3) = "select||newqs$$"&questionList_&"||<br/>新答案："
			formarray2(4) = "input||newans$$$$18$$20||<br/>"
			formarray2(5) = "hidden||a$$12||"&bbsSid&"$$"&sid&"||"
			body_ = body_ &"修改密保问题：<br/>"& hu.getForm(formarray2) &"<br/>[div=tip]修改密保需要验证原来的信息[/div]"& hu.url("bbs_safe.asp", "密保首页")
	Elseif a=12 Then'修改密保
		Dim newqsid,newans
		qsid=getN("qs", 1)
		newqsid=getN("newqs", 1)
		Set rs=hu.conn("select top 1 id from 74hu_passwordask where id="&qsid)
		If rs.eof Then rupt "错误", "请选择密保问题"
		Set rs=hu.conn("select top 1 id from 74hu_passwordask where id="&newqsid)
		If rs.eof Then rupt "错误", "请选择密保问题"
		Set rs=Nothing
		ans=getD("ans", "")
		newans=getD("newans", "")
		If ans="" Or newans="" Then rupt "错误", "密保答案不能为空"&hu.url("bbs_safe.asp","返回密保中心")
		Set rs=hu.conn("select top 1 id from 74hu_password where userid="&userid&" and ask1="&qsid&" and ans1='"&ans&"'")
		If Not rs.eof Then
			hu.conn("update 74hu_password set ask1="&newqsid&",ans1='"&newans&"' where id="&rs("id"))
			body_ = body_ &"密保修改成功！请牢记密保信息<br/>"
		Else
			body_ = body_ &"原来的密保验证失败，请认真填写<br/>"
		End If
		Set rs=Nothing
	Else
		
		body_ = body_ & ""
	End If
	hu.body = comUbb(body_)
End Sub

%>